PROGRAM pauli
IMPLICIT NONE

COMPLEX, DIMENSION(2,2) :: x, y, z, c
INTEGER :: i,j
INTEGER :: d
x=RESHAPE( (/(0,0), (1,0), (1,0), (0,0)/), SHAPE(x) )
y=RESHAPE( (/(0,0), (0,-1), (0,1), (0,0)/), SHAPE(y) )
z=RESHAPE( (/(1,0), (0,0), (0,0), (-1,0)/), SHAPE(z) )

WRITE(*,*), 'Square of Matrices'
WRITE(*,'(A7)',ADVANCE='YES'), 'x*x ='
c=MATMUL(x,x)
DO i=1,2
  WRITE(*,*),(c(i,j),j=1,2)  
END DO
c=MATMUL(y,y)
WRITE(*,'(A7)',ADVANCE='YES'), 'y*y ='
DO i=1,2
  WRITE(*,*),(c(i,j),j=1,2)  
END DO
c=MATMUL(z,z)
WRITE(*,'(A7)',ADVANCE='YES'), 'z*z ='
DO i=1,2
  WRITE(*,*),(c(i,j),j=1,2)  
END DO

WRITE(*,*), 'Determinant of Matrices'
d=x(1,1)*x(2,2) - x(1,2)*x(2,1)
WRITE (*,*),'DET x =',d
d=y(1,1)*y(2,2) - y(1,2)*y(2,1)
WRITE (*,*),'DET y =',d
d=z(1,1)*z(2,2) - z(1,2)*z(2,1)
WRITE (*,*),'DET z =',d

WRITE(*,*), 'Commutation of Matrices'
WRITE(*,'(A7)',ADVANCE='YES'), '[x,y] ='
c=MATMUL(x,y) - MATMUL(y,x)
DO i=1,2
  WRITE(*,*),(c(i,j),j=1,2)  
END DO
WRITE(*,'(A7)',ADVANCE='YES'), '[y,z] ='
c=MATMUL(y,z) - MATMUL(z,y)
DO i=1,2
  WRITE(*,*),(c(i,j),j=1,2)  
END DO
WRITE(*,'(A7)',ADVANCE='YES'),'[z,x] ='
c=MATMUL(z,x) - MATMUL(x,z)
DO i=1,2
  WRITE(*,*),(c(i,j),j=1,2)  
END DO

END PROGRAM
